Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] add functionality to send later scheduled sending #1091

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amaninyumu1
Copy link
Member

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 7aaffb2 to 0c58a6a Compare June 16, 2024 14:58
@marclaporte
Copy link
Member

Will this work with JMAP as well?

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 0c58a6a to 0aef136 Compare June 19, 2024 08:09
@josaphatim josaphatim requested a review from kroky June 19, 2024 08:12
@amaninyumu1 amaninyumu1 marked this pull request as ready for review June 19, 2024 08:12
@kroky
Copy link
Member

kroky commented Jun 20, 2024

Yes, anything we add for IMAP, we should check JMAP support as well. Overall, it is built on top of IMAP, so it should work but please check if the new Scheduled folder is OK for JMAP.

Overall, the code is good but I have one concern - it only sends out while you are actively using Cypht and it seems to warn of unsent/scheduled messages each time you leave a page (onbeforeunload). That would be annoying for the end user. I believe this comment #576 (comment) proposes using sendAt support from jmap servers or scheduled send - if it is supported, we use it, if not, we fallback to a more annoying option. At any rate, it should be configurable.

This could be fully-supported in the Cypht-Tiki integration where there could be a Tiki command run periodically in the scheduler that checks and sends scheduled messages.

@josaphatim
Copy link
Member

@kroky I added a commit to fix issue concerning onbeforeunload event and also add the option to change schedule time or send the message immediately. Can you check please.

@josaphatim josaphatim force-pushed the Cypht-delay-send-later-scheduled-sending branch 2 times, most recently from 36599a8 to 2da4ff4 Compare June 27, 2024 13:45
@marclaporte
Copy link
Member

@amaninyumu1 If you need help with JMAP, please reach out to @Shadow243 as he set up a JMAP server for testing.

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch 2 times, most recently from 45374ae to bdf9d5d Compare July 29, 2024 20:29
@Baraka24 Baraka24 force-pushed the Cypht-delay-send-later-scheduled-sending branch 5 times, most recently from cf0574d to af1c185 Compare August 2, 2024 10:21
@marclaporte
Copy link
Member

@amaninyumu1 "This branch has conflicts that must be resolved"

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch 2 times, most recently from 141f8d9 to 16293f5 Compare September 14, 2024 06:13
@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 16293f5 to 41c9b95 Compare September 26, 2024 06:16
@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 41c9b95 to 3fb7802 Compare October 8, 2024 02:47
@marclaporte
Copy link
Member

@amaninyumu1 This branch has conflicts that must be resolved

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 3fb7802 to e725bcc Compare October 22, 2024 19:54
@amaninyumu1
Copy link
Member Author

Hello @marclaporte , @kroky I resolved the conflicts. please review

modules/smtp/modules.php Outdated Show resolved Hide resolved
}
} catch (Exception $e) {
Hm_Debug::add(sprintf('ERRCannot send message: %s', $msg_headers['subject']));
if (send_scheduled_message($this, $imap, $msg, $server_id)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you retry sending in some other way, combine the above sending with the one in this method, so we don't repeat so much code.

}}

if (!hm_exists('reschedule_message_sending')) {
function reschedule_message_sending($handler, $imap, $msg_id, $folder, $new_date, $server_id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use modules.php only for handle or output modules. Move the functions to its own functions.php file to keep the existing structure in other modules (e.g. imap and core).

@kroky
Copy link
Member

kroky commented Oct 23, 2024

There are still conflicts and I believe big part of the reason is #1266 - @jacob-js , can you check if some handlers in this PR need to be updated according to the router changes you did in 1266?

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from e725bcc to e3825fe Compare October 24, 2024 12:01
Comment on lines 772 to 806
class_name = 'imap_' + detail.server_id + '_' + msg_uid + '_' + detail.folder;
if (hm_list_parent() === 'combined_inbox') {
Hm_Message_List.prev_next_links('formatted_combined_inbox', class_name);
}
else if (hm_list_parent() === 'unread') {
Hm_Message_List.prev_next_links('formatted_unread_data', class_name);
}
else if (hm_list_parent() === 'flagged') {
Hm_Message_List.prev_next_links('formatted_flagged_data', class_name);
}
else if (hm_list_parent() === 'advanced_search') {
Hm_Message_List.prev_next_links('formatted_advanced_search_data', class_name);
}
else if (hm_list_parent() === 'search') {
Hm_Message_List.prev_next_links('formatted_search_data', class_name);
}
else if (hm_list_parent() === 'sent') {
Hm_Message_List.prev_next_links('formatted_sent_data', class_name);
}
else if (hm_list_parent() === 'junk') {
Hm_Message_List.prev_next_links('formatted_junk_data', class_name);
}
else if (hm_list_parent() === 'trash') {
Hm_Message_List.prev_next_links('formatted_trash_data', class_name);
}
else if (hm_list_parent() === 'drafts') {
Hm_Message_List.prev_next_links('formatted_drafts_data', class_name);
}
else if (hm_list_parent() === 'tag') {
Hm_Message_List.prev_next_links('formatted_tag_data', class_name);
}
else {
var key = 'imap_' + Hm_Utils.get_url_page_number() + '_' + getListPathParam();
Hm_Message_List.prev_next_links(key, class_name);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rebase isn't accurate. Master has passed over these changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amaninyumu1 I think you should be careful merging the changes from master - there are conflicts because of the upstream changes and these need to be merged correctly (keep the master ones and copy your code to the relevant places).

if (!uid) {
uid = getMessageUidParam();
}
const callbackFn = (...args) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you avoid such changes in the future? it's really difficult to focus on what has actually changed.

@jacob-js
Copy link
Member

The small piece of code added won't need an update since it is not executed on page loads.

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from e3825fe to 729dc43 Compare October 24, 2024 19:40
@amaninyumu1 amaninyumu1 reopened this Oct 25, 2024
@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from b34ef74 to bbf3b65 Compare October 26, 2024 10:58
Comment on lines +1969 to +1980
var sprintf = function(format, ...args) {
let i = 0;
return format.replace(/%([sd])/g, (match, type) => {
let arg = args[i++];
switch (type) {
case 's': return String(arg);
case 'd': return Number(arg);
default: return match;
}
});
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. If including variables in a string is all you need, you can use template literals.

@@ -2012,6 +2025,12 @@ $(function() {
try { navigator.registerProtocolHandler("mailto", "?page=compose&compose_to=%s", "Cypht"); } catch(e) {}
}

if (hm_page_name() == 'home') {
$('.pw_update').on("click", function() { update_password($(this).data('id')); });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the same statement already in route_handlers.js. So, you don't need to have it here anymore besides the fact that adding handlers based on the hm_page_name() is already outdated in favor of the route handlers in each module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacob-js I made some modifications by removing the hm_page_name() in the core module js file. please review

$('.pw_update').on("click", function() { update_password($(this).data('id')); });
}
if (hm_page_name() == 'servers') {
$('.edit_server_connection').on('click', imap_smtp_edit_action);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do the same here. Check if the statement is not yet in the serversPageHandlers and move it to there.

Comment on lines +1239 to +1253
if (hm_page_name() === 'message_list' && hm_list_path().substr(0, 4) === 'imap') {
setup_imap_folder_page();
}
else if (hm_page_name() === 'message_list' && hm_list_path() === 'combined_inbox') {
setup_imap_message_list_content_page();
}
else if (hm_page_name() === 'message' && hm_list_path().substr(0, 4) === 'imap') {
imap_setup_message_view_page();
}
else if (hm_page_name() === 'servers') {
imap_setup_server_page();
}
else if (hm_page_name() === 'info') {
setTimeout(imap_status_update, 100);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this should not be here anymore.

if (hm_page_name() === 'message_list' || hm_page_name() === 'message') {
imap_setup_snooze();
imap_setup_tags();
setup_nexter_date(function(e) {
Copy link
Member

@jacob-js jacob-js Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this function call to the appropriate page handlers

@@ -427,3 +436,264 @@ function smtpSettingsPageHandler() {
);
});
}
$(function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master has passed over these changes. If you have additional lines of code, ensure they are in the right route handlers.

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from bbf3b65 to 5f0695c Compare October 30, 2024 09:50
@amaninyumu1
Copy link
Member Author

Hello @jacob-js I don't understand very well please

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 5f0695c to 740bf92 Compare October 30, 2024 14:37
@jacob-js
Copy link
Member

Hello @jacob-js I don't understand very well please

I added more details in your inbox, I hope it becomes clear!

@amaninyumu1 amaninyumu1 force-pushed the Cypht-delay-send-later-scheduled-sending branch from 740bf92 to 4698358 Compare October 30, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants